

#include "mpi_lib.h"
#include "mpi.h"


#include "mpi_sys.h"

static sgks_mpi_manager_s *g_manager = NULL;
static u32	g_mem_amount = 0;

#ifdef DEBUG
#define DEBUGMASK(bit)       (1 << (bit))
#define MASK_ERROR           DEBUGMASK(0)
#define MASK_WARN            DEBUGMASK(1)
#define MASK_INIT            DEBUGMASK(2)
#define MASK_FUNCTION        DEBUGMASK(3)
#define MASK_IOCTL           DEBUGMASK(4)
#define MASK_THREAD          DEBUGMASK(5)
#define MASK_INFO            DEBUGMASK(6)
#define MASK_VENC            DEBUGMASK(7)
#define MASK_OSD             DEBUGMASK(8)

DBGPARAM dpCurSettings =
{
    "MPI",
    {
        "Errors", "Warnings", "Init", "Function",
        "Ioctl", "Thread", "Info", "Venc",
        "Osd", "", "", "",
        "", "", "", "",
    },
    MASK_ERROR | MASK_WARN | MASK_INIT | MASK_FUNCTION | MASK_INFO | MASK_VENC | MASK_OSD/*| MASK_THREAD*/,
};
#endif
sgks_mpi_manager_s **mpi_get_managerHanleAddr()
{
    return &g_manager;
}

sgks_mpi_manager_s *mpi_get_managerHanle()
{

    CHECK_POINT_NULL_RETURN(g_manager, NULL);
    return g_manager;

}

int mpi_start()
{



    return SGKS_SUCCESS;
}


int mpi_stop()
{



    return SGKS_SUCCESS;
}


void* sgks_mpi_Malloc(int size)
{
    void *true_ptr = malloc(size);

    if (true_ptr == NULL)
    {
		Printf("malloc err\n");
		return NULL;
    }
		
    memset(true_ptr, 0, size);
    g_mem_amount+= size;

	Printf("[malloc] curr mem use size %d\n",g_mem_amount);
	

    return true_ptr;
}

void sgks_mpi_Free(void* ptr)
{
    if (ptr == NULL)
    {
        Printf("free err\n");
		return ;
    }
	
	int size = malloc_usable_size(ptr);

	free(ptr);

	g_mem_amount-= size;

	Printf("[free] curr mem use size %d\n",g_mem_amount);

}



